package com.tian.core.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.apache.struts2.json.annotations.JSON;

/**
 * Master entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "master", catalog = "portalservermond", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class Master implements java.io.Serializable {

	// Fields

	private Integer id;
	private Depart depart;
	private String name;
	private String password;
	private Date bdate;
	private String truename;
	private String sex;
	private Date birthday;
	private String dept;
	private String position;
	private String positionDesc;
	private Long officePhone;
	private Long mobile;
	private Long homePhone;
	private String email;
	private Integer masterid;
	private String mastername;
	private Date createdate;
	private Set<Mastergroup> mastergroups = new HashSet<Mastergroup>(0);

	// Constructors

	/** default constructor */
	public Master() {
	}

	/** minimal constructor */
	public Master(Depart depart, String name, String password) {
		this.depart = depart;
		this.name = name;
		this.password = password;
	}

	/** full constructor */
	public Master(Depart depart, String name, String password, Date bdate,
			String truename, String sex, Date birthday, String dept,
			String position, String positionDesc, Long officePhone,
			Long mobile, Long homePhone, String email, Integer masterid,
			String mastername, Date createdate,
			Set<Mastergroup> mastergroups) {
		this.depart = depart;
		this.name = name;
		this.password = password;
		this.bdate = bdate;
		this.truename = truename;
		this.sex = sex;
		this.birthday = birthday;
		this.dept = dept;
		this.position = position;
		this.positionDesc = positionDesc;
		this.officePhone = officePhone;
		this.mobile = mobile;
		this.homePhone = homePhone;
		this.email = email;
		this.masterid = masterid;
		this.mastername = mastername;
		this.createdate = createdate;
		this.mastergroups = mastergroups;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	@JSON(serialize = false)
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "deptid", nullable = false)
	public Depart getDepart() {
		return this.depart;
	}

	public void setDepart(Depart depart) {
		this.depart = depart;
	}

	@Column(name = "name", unique = true, nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "password", nullable = false, length = 100)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "bdate", length = 0)
	public Date getBdate() {
		return this.bdate;
	}

	public void setBdate(Date bdate) {
		this.bdate = bdate;
	}

	@Column(name = "truename", length = 100)
	public String getTruename() {
		return this.truename;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	@Column(name = "sex", length = 2)
	public String getSex() {
		return this.sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Column(name = "birthday", length = 0)
	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Column(name = "dept", length = 100)
	public String getDept() {
		return this.dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	@Column(name = "position", length = 100)
	public String getPosition() {
		return this.position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	@Column(name = "position_desc", length = 100)
	public String getPositionDesc() {
		return this.positionDesc;
	}

	public void setPositionDesc(String positionDesc) {
		this.positionDesc = positionDesc;
	}

	@Column(name = "office_phone", precision = 10, scale = 0)
	public Long getOfficePhone() {
		return this.officePhone;
	}

	public void setOfficePhone(Long officePhone) {
		this.officePhone = officePhone;
	}

	@Column(name = "mobile", precision = 10, scale = 0)
	public Long getMobile() {
		return this.mobile;
	}

	public void setMobile(Long mobile) {
		this.mobile = mobile;
	}

	@Column(name = "home_phone", precision = 10, scale = 0)
	public Long getHomePhone() {
		return this.homePhone;
	}

	public void setHomePhone(Long homePhone) {
		this.homePhone = homePhone;
	}

	@Column(name = "email", length = 100)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "masterid")
	public Integer getMasterid() {
		return this.masterid;
	}

	public void setMasterid(Integer masterid) {
		this.masterid = masterid;
	}

	@Column(name = "mastername", length = 100)
	public String getMastername() {
		return this.mastername;
	}

	public void setMastername(String mastername) {
		this.mastername = mastername;
	}

	@Column(name = "createdate", length = 0)
	public Date getCreatedate() {
		return this.createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}
	@JSON(serialize = false)
	//@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "master")
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "master")
	public Set<Mastergroup> getMastergroups() {
		return this.mastergroups;
	}

	public void setMastergroups(Set<Mastergroup> mastergroups) {
		this.mastergroups = mastergroups;
	}

}